<?php

function cleanup_GET_array() {

     // Check if non_specific_dates are posted
     if (isset($_GET['non_specific_dates'])):
          unset($_GET['check_in']);
          unset($_GET['check_out']);
          $_GET['nr_adults'] = 2;
          $_GET['nr_childrens'] = 0;
          unset($_GET['ages']);
     endif;
     
     // cleanup ages
     if (isset($_GET['ages'])):

          $count = count($_GET['ages']);

          for ($i = $_GET['nr_childrens']; $i < $count; $i++):
               unset($_GET['ages'][$i]);
          endfor;

          if (count($_GET['ages']) == 0 || $_GET['nr_childrens'] == 0):
               unset($_GET['ages']);
          endif;

     endif;
}

?>
